<template>
  <div>
    <div class="jiaocaibox">
      <div class="tlist">
        <div class="titem">所有教材</div>
      </div>
      <div class="clist">
        <div class="citem" v-for="(item, index) of list" :key="index" @click="$router.push({path:'/jiaocai',query:{'id':item.id}})">
          <img :src="item.cover" alt="">
          <div class="info">
            <h3>{{item.title}}</h3>
            <p class="price">￥{{item.price/100}}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BottomNav from './BottomNav'
import * as info from '../api/info'
export default {
  name: 'jiaocailist',
  data: function () {
    return {
      list: [],
      items: [
        // {
        //   name: '英语语法突破五步法突破五步法破五步法突',
        //   img: '../../static/images/pic.jpg',
        //   price: '56.5',
        //   intro: '英语语法突破五步法突破五步法突破五步法突破五步法英语语法突破五步法突破五步法英语语法突破五步法突破五步法'
        // },
        // {
        //   name: '英语语法突破五步法',
        //   img: '../../static/images/pic.jpg',
        //   price: '56.5',
        //   intro: '英语语法突破五步法突破五步法突破五步法突破五步法英语语法突破五步法突破五步法英语语法突破五步法突破五步法'
        // },
        // {
        //   name: '英语语法突破五步法',
        //   img: '../../static/images/pic.jpg',
        //   price: '56.5',
        //   intro: '英语语法法突破五步法突破五步法'
        // },
        // {
        //   name: '英语语法突破五步法',
        //   img: '../../static/images/pic.jpg',
        //   price: '56.5',
        //   intro: '英语语法突破五步法突破五步法英语语法突破五步法突破五步法英语语法突破五步法突破五步法'
        // }
      ]
    }
  },
  methods:{
    getJiaoCaiList () {
      info.getBookList().then(res => {
        console.log(res)
        this.list = res.data
      })
    }
  },
  mounted () {
    this.getJiaoCaiList()
  },
  components: {
    'bottom-nav': BottomNav
  }
}
</script>

<style scoped>
.tlist{
  display: flex;
  height: 1.2rem;
  align-items: center;
  border-bottom: 1px solid #aaa;
}
.titem{
  font-size: .42rem;
  padding: 0 .4rem;
  font-weight: bold;
  border-right: 1px solid #eee;
}
.titem.active{
  color: #007aff;
}
.clist{
}
.citem{
  border-bottom: .1rem solid #f1f1f1;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: .3rem .3rem;
}
.citem img{
  display: block;
  width: 3.4rem;
  height: 2.54rem;
  flex-shrink: 0;
  margin-right: .3rem;
  border: 1px solid #d1d1d1;
}
.info{
  width: 5.7rem;
}
.info h3{
  font-size: .42rem;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #000;
}
.info .price{
  color: #ed702d;
  font-size: .42rem;
  font-weight: bold;
}
.info .intro{
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  line-height: .46rem;
  margin-top: .2rem;
  font-size: .34rem;
}

</style>
